/* $Id:area.h $ */
/*
   Copyright (C) 2007 by Jurjen Stellingwerff <jurjen@stwerff.xs4all.nl>
   Part of the Moros Project http://moros.sourceforge.net/

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License version 3.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details.
*/

#ifndef __AREA_H
#define __AREA_H

#include <string>
#include <map>
#include <list>
using namespace std;



class area {
    int nr;
    int terrain;
    int river_e;
    int river_ne;
    int river_nw;
    int road_e;
    int road_ne;
    int road_nw;
public:
    area();

    // Field : nr
    const int getNr() const;
    void setNr(const int v);
    int operator<(const class area &ck) const;

    // Field : terrain
    enum terrain_enum{terrain_ocean,terrain_coast,terrain_ford,terrain_lava,terrain_ice,terrain_cave,terrain_field,terrain_grass,terrain_forest,terrain_tropical,terrain_dirt,terrain_swamp,terrain_desert,terrain_deserthills,terrain_desertmountains,terrain_mountains};
    const int getTerrain() const;
    const string showTerrain() const;
    void setTerrain(const int v);
    void setTerrain(const string v);

    // Field : river_e
    enum river_e_enum{river_e_open,river_e_river,river_e_river_dike,river_e_dike,river_e_wall};
    const int getRiver_e() const;
    const string showRiver_e() const;
    void setRiver_e(const int v);
    void setRiver_e(const string v);

    // Field : river_ne
    enum river_ne_enum{river_ne_open,river_ne_river,river_ne_river_dike,river_ne_dike,river_ne_wall};
    const int getRiver_ne() const;
    const string showRiver_ne() const;
    void setRiver_ne(const int v);
    void setRiver_ne(const string v);

    // Field : river_nw
    enum river_nw_enum{river_nw_open,river_nw_river,river_nw_river_dike,river_nw_dike,river_nw_wall};
    const int getRiver_nw() const;
    const string showRiver_nw() const;
    void setRiver_nw(const int v);
    void setRiver_nw(const string v);

    // Field : road_e
    enum road_e_enum{road_e_nothing,road_e_broken,road_e_normal,road_e_good};
    const int getRoad_e() const;
    const string showRoad_e() const;
    void setRoad_e(const int v);
    void setRoad_e(const string v);

    // Field : road_ne
    enum road_ne_enum{road_ne_nothing,road_ne_broken,road_ne_normal,road_ne_good};
    const int getRoad_ne() const;
    const string showRoad_ne() const;
    void setRoad_ne(const int v);
    void setRoad_ne(const string v);

    // Field : road_nw
    enum road_nw_enum{road_nw_nothing,road_nw_broken,road_nw_normal,road_nw_good};
    const int getRoad_nw() const;
    const string showRoad_nw() const;
    void setRoad_nw(const int v);
    void setRoad_nw(const string v);

    void save(class channel &ch);
    void load(class channel &ch);
    void xml(ofstream &f, int l=0, int r=0);
};

// Repository

#define loopAreas(v) loopMapi(area_repo.listArea(),v,class area)

class areaRepository {
    map<int,class area> areas;
    int max_nr;
public:
    areaRepository();
    class area& getArea(const int v);
    void setArea(class area& v);
    map<int,class area>& listArea();
    void delArea(const int v);
    const bool isArea(const int v) const;
    bool load(class channel &ch);
    void save(class channel &ch);
};

extern areaRepository area_repo;

#endif // __AREA_H
